import cloud from '@hw-agconnect/cloud'
import schema from '../../resources/rawfile/schema.json'
import { Database } from '@hw-agconnect/cloud/src/main/ets/database/Database'
import { qtype } from '../models/qtype'
import { chapqa } from '../models/chapqa'
import { chaplist } from '../models/chaplist'

export class DatabaseHelper{
  static database: Database = cloud.database({objectTypeInfo: schema, zoneName: "hmqaZone"})
  //1.获取考题大类数据
  static async QType_Query(): Promise<qtype[]>{
    return await DatabaseHelper.database.collection(qtype)
      .query()
      .get()
  }
  //2. 根据题库分类id获取其下面的所有章节数据，并且按照order进行升序排列
  static async ChapList_Query(qtypeid:number):Promise<chaplist[]> {

    return await DatabaseHelper.database.collection(chaplist).query().equalTo("qid",qtypeid).orderByAsc('order').get();

  }
}

export default DatabaseHelper